﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

using RobotCtrl;

namespace RobotView
{
    public partial class DriveView : UserControl
    {
        //Either virtual or real
        private Drive driveConsole;

        public DriveView(RunMode mode)
        {
            InitializeComponent();
            this.driveConsole = new Drive(mode);
        }

        public DriveView()
            :this(RunMode.VIRTUAL)
        {
        }

        /// <summary>
        /// Turns power for both motors on
        /// </summary>
        private void btnOn_Click(object sender, EventArgs e)
        {
            this.driveConsole.Power = true;
            this.timUpdateGUI.Enabled = true;
        }

        /// <summary>
        /// Turns power for both motors off
        /// </summary>
        private void btnOff_Click(object sender, EventArgs e)
        {
            this.driveConsole.Power = false;
            this.driveConsole.Stop();
            this.timUpdateGUI.Enabled = false;
        }

        private void trkbarSpeedControlLeft_ValueChanged(object sender, EventArgs e)
        {
            //this.driveConsole.SetSpeed(this.trkbarSpeedControlLeft.Value, Int32.MaxValue);
        }

        private void trkbarSpeedControlRight_ValueChanged(object sender, EventArgs e)
        {
            //this.driveConsole.SetSpeed(Int32.MaxValue, this.trkbarSpeedControlRight.Value);
        }

        private void timUpdateGUI_Tick(object sender, EventArgs e)
        {/*
            double currentSpeedLeft;
            double currentSpeedRight;
            int currentTickCountLeft;
            int currentTickCountRight;
          */
            //now get me all the information from the driveCtrl
            /*
            this.driveConsole.GetSpeed(out currentSpeedLeft, out currentSpeedRight);
            this.driveConsole.GetTicks(out currentTickCountLeft, out currentTickCountRight);
            
            this.trkbarSpeedControlLeft.Value = (int)currentSpeedLeft;
            this.trkbarSpeedControlRight.Value = (int)currentSpeedRight;
            this.lblSpeedLeft.Text = ((int)currentSpeedLeft).ToString();
            this.lblSpeedRight.Text = ((int)currentSpeedRight).ToString();
            this.lblTicksLeft.Text = currentTickCountLeft.ToString();
            this.lblTicksRight.Text = currentTickCountRight.ToString();
             */
        }
    }
}
